import 'package:demo202112/utils/common_appbar.dart';
import 'package:demo202112/wy_gesture_willPopScope.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'my_one_page.dart';

/**
 * @Author wywinstonwy
 * @Date 2022/1/9 10:28 下午
 * @Description:
 */

class MyHomePage1 extends StatefulWidget {
  MyHomePage1({required Key key, required this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePage1State createState() => _MyHomePage1State();
}

class _MyHomePage1State extends State<MyHomePage1> {

  GlobalKey<NavigatorState> _key = GlobalKey();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: getAppBar('Navigator'),
      body:SwipeLeftReturnWidget(Column(
        children: <Widget>[
          Expanded(
            child: Navigator(
              key: _key,
              onGenerateRoute: (RouteSettings settings) =>
                  MaterialPageRoute(builder: (context) {
                    return OnePage();
                  }),
            ),
          ),
          Container(
            height: 64,
            color: Colors.blue,
            alignment: Alignment.center,
            child: Text('底部Bar'),
          )
        ],
      ))
    //   body: WillPopScope(
    //       onWillPop: () async {
    //         if (_key.currentState!.canPop()) {
    //           _key.currentState!.pop();
    //           print("拦截-----");
    //           return false;
    //         }
    //         print("返回-----");
    //         return true;
    //       },
    //       child: Column(
    //         children: <Widget>[
    //           Expanded(
    //             child: Navigator(
    //               key: _key,
    //               onGenerateRoute: (RouteSettings settings) =>
    //                   MaterialPageRoute(builder: (context) {
    //                     return OnePage();
    //                   }),
    //             ),
    //           ),
    //           Container(
    //             height: 64,
    //             color: Colors.blue,
    //             alignment: Alignment.center,
    //             child: Text('底部Bar'),
    //           )
    //         ],
    //       )
    // ),
    );
  }

}